package me.yobol.lintcode.easy.maxdepth;

import me.yobol.lintcode.TreeNode;

/**
 *
 * @author Yobol
 */
public class RecursiveMaxDepth implements IMaxDepth{

    @Override
    public int maxDepth(TreeNode root) {
        if (root == null) {
            return 0;
        }else {
            int leftDepth = maxDepth(root.left);
            int rightDepth = maxDepth(root.right);
            return (leftDepth > rightDepth ? leftDepth : rightDepth) + 1;
        }
    }
    
}
